package com.repair.common.base;

import com.jfinal.core.Controller;
import com.jfinal.kit.HttpKit;
import com.jfinal.kit.JsonKit;
import com.jfinal.kit.Ret;


public class BaseController extends Controller {
	public void renderJsonResult(Object result) {
		Ret ret = new Ret();
		ret.set("_success", true);
		ret.set("_message", "");
		ret.set("result", result);
		renderJson(ret);
	}

	public void renderJsonSuccess() {
		Ret ret = new Ret();
		ret.set("_success", true);
		ret.set("_message", "");
		renderJson(ret);
	}
	public <T> T getRequestBody(Class<T> t){
		String jsonStr = HttpKit.readData(getRequest());
		T result = JsonKit.parse(jsonStr, t);
		return result;
	}
}
